//
//  YSCardVideoItemView.m
//  Yueshi
//
//  Created by yueshi－mac1 on 15/12/16.
//  Copyright © 2015年 悦食中国. All rights reserved.
//

#import "YSCardVideoItemView.h"
#import "VideoPlayView.h"

@interface YSCardVideoItemView()
@property(strong, nonatomic) VideoPlayView *videoView;
@property(strong, nonatomic) UIImageView *iconImage;
@property(strong, nonatomic) UILabel *descLabel;
@property(strong, nonatomic) UILabel *subDescLabel;
@end

@implementation YSCardVideoItemView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //商品图片
        VideoPlayView *videoView = [[VideoPlayView alloc] init];
        [self addSubview:videoView];
        self.videoView = videoView;
        
        //描述前的icon
        UIImageView *iconImage = [[UIImageView alloc]init];
        [self addSubview:iconImage];
        self.iconImage = iconImage;
        
        //描述
        UILabel *descLabel = [[UILabel alloc] init];
        descLabel.textColor = DescColor;
        descLabel.font = SYS_FONT(DescFont);
        [self addSubview:descLabel];
        self.descLabel = descLabel;
        
        //子描述
        UILabel *subDescLabel = [[UILabel alloc] init];
        subDescLabel.textColor = SubDescColor;
        subDescLabel.font = SYS_FONT(SubDescFont);
        [self addSubview:subDescLabel];
        self.subDescLabel = subDescLabel;
    }
    return self;
}


- (void)setCardVideoFrame:(YSCardVideoItemFrame *)cardVideoFrame{
    _cardVideoFrame = cardVideoFrame;
    
    YSAdvert *advert =  cardVideoFrame.advert;
    self.videoView.frame = cardVideoFrame.videoFrame;
    self.videoView.videoUrlStr = advert.advertVideoUrl;
    
    if(!ISBLANK(advert.advertTitle)){
        [self.iconImage setImageURLStr:advert.advertIcon];
        [self.iconImage setContentMode:UIViewContentModeScaleToFill];
        self.iconImage.frame = cardVideoFrame.iconImageFrame;
        
        [self.descLabel setText:advert.advertTitle];
        self.descLabel.frame = cardVideoFrame.descFrame;
        
        [self.subDescLabel setText:advert.advertText];
        self.subDescLabel.frame = cardVideoFrame.subDescFrame;
    }else if(!ISBLANK(advert.advertText)){
        [self.subDescLabel setText:advert.advertText];
        self.subDescLabel.frame = cardVideoFrame.subDescFrame;
    }
    
    self.frame = cardVideoFrame.frame;
}


@end
